/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package systole.domain.clinicalInformation;

import java.io.Serializable;
import systole.domain.persons.Patient;

/**
 * 
 * @author jmj
 */
public class FamilyPatientBackground implements Serializable {

    /**
     *
     */
    private static final long serialVersionUID = 3805878018304710165L;
    private FamilyPatientBackgroundId id;
    private Patient patient;
    private Family family;
    private Boolean backgroundCardiac;
    private Boolean backgroundDiabetic;
    private Boolean backgroundCholesterol;
    private Boolean backgroundHypertension;

    /**
     * 
     */
    public FamilyPatientBackground() {
        super();
    }

    /**
     * @param patient
     */
    public FamilyPatientBackground(Patient patient) {
        this.patient = patient;
    }

    /**
     * @param id
     * @param patient
     * @param family
     */
    public FamilyPatientBackground(FamilyPatientBackgroundId id,
            Patient patient, Family family) {
        this.id = id;
        this.patient = patient;
        this.family = family;
    }

    /**
     * @return the id
     */
    public FamilyPatientBackgroundId getId() {
        return id;
    }

    /**
     * @param id
     *            the id to set
     */
    public void setId(FamilyPatientBackgroundId id) {
        this.id = id;
    }

    /**
     * @return the patient
     */
    public Patient getPatient() {
        return patient;
    }

    /**
     * @param patient
     *            the patient to set
     */
    public void setPatient(Patient patient) {
        this.patient = patient;
    }

    /**
     * @return the family
     */
    public Family getFamily() {
        return family;
    }

    /**
     * @param family
     *            the family to set
     */
    public void setFamily(Family family) {
        this.family = family;
    }

    /**
     * @return the backgroundCardiac
     */
    public Boolean getBackgroundCardiac() {
        return backgroundCardiac;
    }

    /**
     * @param backgroundCardiac
     *            the backgroundCardiac to set
     */
    public void setBackgroundCardiac(Boolean backgroundCardiac) {
        this.backgroundCardiac = backgroundCardiac;
    }

    /**
     * @return the backgroundDiabetic
     */
    public Boolean getBackgroundDiabetic() {
        return backgroundDiabetic;
    }

    /**
     * @param backgroundDiabetic
     *            the backgroundDiabetic to set
     */
    public void setBackgroundDiabetic(Boolean backgroundDiabetic) {
        this.backgroundDiabetic = backgroundDiabetic;
    }

    /**
     * @return the backgroundCholesterol
     */
    public Boolean getBackgroundCholesterol() {
        return backgroundCholesterol;
    }

    /**
     * @param backgroundCholesterol
     *            the backgroundCholesterol to set
     */
    public void setBackgroundCholesterol(Boolean backgroundCholesterol) {
        this.backgroundCholesterol = backgroundCholesterol;
    }

    /**
     * @return the backgroundHypertension
     */
    public Boolean getBackgroundHypertension() {
        return backgroundHypertension;
    }

    /**
     * @param backgroundHypertension
     *            the backgroundHypertension to set
     */
    public void setBackgroundHypertension(Boolean backgroundHypertension) {
        this.backgroundHypertension = backgroundHypertension;
    }

    /**
     * @return if at least has a background
     */
    public boolean hasAnyBackground() {
        return (((this.backgroundCardiac != null) && (this.backgroundCardiac.booleanValue()))
                || ((this.backgroundCholesterol != null) && (this.backgroundCholesterol.booleanValue()))
                || ((this.backgroundDiabetic != null) && (this.backgroundDiabetic.booleanValue())) || ((this.backgroundHypertension != null) && (this.backgroundHypertension.booleanValue())));
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final FamilyPatientBackground other = (FamilyPatientBackground) obj;
        if (this.id != other.id
                && (this.id == null || !this.id.equals(other.id))) {
            return false;
        }
        if (this.patient != other.patient
                && (this.patient == null || !this.patient.equals(other.patient))) {
            return false;
        }
        if (this.family != other.family
                && (this.family == null || !this.family.equals(other.family))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 19 * hash + (this.id != null ? this.id.hashCode() : 0);
        hash = 19 * hash + (this.patient != null ? this.patient.hashCode() : 0);
        hash = 19 * hash + (this.family != null ? this.family.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString() {
        String result = this.family.toString() + " presenta";
        boolean oneOrMore = false;
        if (this.backgroundCardiac) {
            result = result.concat(" antecedentes cardíacos");
            oneOrMore = true;
        }
        if (this.backgroundCholesterol) {
            result = result.concat((oneOrMore ? ", " : "")
                    + " antecedentes de coresterol");
            oneOrMore = true;
        }
        if (this.backgroundDiabetic) {
            result = result.concat((oneOrMore ? ", " : "")
                    + " antecedentes de diabetes");
            oneOrMore = true;
        }
        if (this.backgroundHypertension) {
            result = result.concat((oneOrMore ? ", " : "")
                    + " antecedentes de hipértensión");
            oneOrMore = true;
        }
        if (!oneOrMore) {
            result = this.family.toString() + " no presenta antecedente alguno";
        }
        return result;
    }
}
